/*
 * @Description: question
 * @Autor: GuluGuluu
 * @Date: 2023-06-26 21:00:34
 * @LastEditors: GuluGuluu
 * @LastEditTime: 2023-07-03 23:18:55
 */
export const questionManageConfig = {
  type: "crud",
  id: "u:72ee6104cd95",
  syncLocation: false,
  api: {
    method: "get",
    url: "http://localhost:8080/question/questionlist",
    messages: {},
    requestAdaptor: "",
    dataType: "json",
    adaptor:
      "const map = {\r\n  'blank': '填空题',\r\n  'select': '选择题',\r\n  'picture': '主观题'\r\n}\r\nconst rows = payload.data.rows.map(v => ({ ...v, type: map[v.type] }));\r\nreturn { rows, total: payload.data.total }",
  },
  columns: [
    {
      name: "id",
      label: "ID",
      type: "text",
      id: "u:c1a7ff570c20",
    },
    {
      type: "text",
      label: "类型",
      name: "type",
      id: "u:c0d2b2fb7767",
      placeholder: "-",
      quickEdit: false,
      popOver: false,
    },
    {
      type: "text",
      label: "内容",
      id: "u:e1dc1a2975a8",
      name: "content",
      placeholder: "-",
      popOver: {
        type: "panel",
        title: "题目详情",
        body: [
          {
            type: "tpl",
            tpl: "${content}",
            wrapperComponent: "",
            inline: false,
            id: "u:8241c6dd0e5c",
            hiddenOn: "${STARTSWITH(content, 'http')}",
          },
        ],
        id: "u:f3242260fd48",
        actions: [
          {
            type: "flex",
            id: "u:b76e50629a7e",
            className: "p-1",
            items: [
              {
                type: "container",
                body: [
                  {
                    type: "image",
                    id: "u:a588c87c8810",
                    width: 100,
                    height: 242,
                    enlargeAble: true,
                    imageMode: "original",
                    src: "",
                    hiddenOn: "${!STARTSWITH(content, 'http')}",
                    thumbRatio: "4:3",
                    className: "",
                    thumbClassName: "",
                    imageClassName: "image-amis",
                  },
                ],
                size: "xs",
                style: {
                  position: "static",
                  display: "block",
                  flex: "1 1 auto",
                  flexGrow: 1,
                  flexBasis: "auto",
                },
                wrapperBody: false,
                isFixedHeight: false,
                isFixedWidth: false,
                id: "u:1bbc9b245ce4",
              },
            ],
            style: {
              position: "relative",
              inset: "auto",
              flexWrap: "nowrap",
              width: "100%",
              overflowX: "auto",
              margin: "0",
              height: "100%",
              overflowY: "auto",
            },
            isFixedHeight: true,
            isFixedWidth: true,
          },
        ],
        affixFooter: false,
        hidden: false,
        mode: "dialog",
      },
    },
    {
      type: "operation",
      label: "操作",
      buttons: [
        {
          label: "编辑",
          type: "button",
          actionType: "dialog",
          level: "link",
          dialog: {
            title: "编辑",
            body: [
              {
                type: "form",
                api: {
                  method: "put",
                  url: "http://localhost:8080/question",
                  requestAdaptor: "",
                  adaptor: "",
                  messages: {},
                  dataType: "json",
                },
                body: [
                  {
                    name: "id",
                    label: "id",
                    id: "u:849104ed4128",
                    type: "input-text",
                    static: true,
                    readOnly: false,
                  },
                  {
                    name: "type",
                    label: "题目类型",
                    id: "u:1913d736e30d",
                    type: "input-text",
                    hidden: true,
                  },
                  {
                    type: "input-text",
                    name: "content",
                    label: "内容",
                    id: "u:e1dc1a2975a8",
                    hiddenOn: "${type == '主观题'}",
                    required: true,
                  },
                  {
                    type: "input-image",
                    name: "content",
                    label: "题目上传",
                    id: "u:f2816f575828",
                    autoUpload: false,
                    proxy: false,
                    uploadType: "fileReceptor",
                    imageClassName: "r w-full",
                    accept: ".jpeg, .jpg, .png, .gif",
                    multiple: false,
                    hideUploadButton: false,
                    hiddenOn: "${type != '主观题'}",
                    bos: "default",
                    clearValueOnHidden: true,
                    required: true,
                    receiver: {
                      url: "http://localhost:8080/question/upload",
                      method: "post",
                      requestAdaptor: "",
                      adaptor: "",
                      messages: {},
                      dataType: "form-data",
                    },
                  },
                ],
                id: "u:16cf86db4b84",
              },
            ],
            type: "dialog",
            id: "u:1567d833ea97",
          },
          id: "u:5f626b539121",
        },
        {
          type: "button",
          label: "删除",
          actionType: "ajax",
          level: "link",
          className: "text-danger",
          confirmText: "确定要删除？",
          api: {
            method: "delete",
            url: "http://localhost:8080/question/$id",
            requestAdaptor: "",
            adaptor: "",
          },
          id: "u:c5a57be2023c",
        },
      ],
      id: "u:8bff89a3dd6a",
    },
  ],
  bulkActions: [],
  itemActions: [],
  features: ["create", "update", "delete", "view", "filter"],
  headerToolbar: [
    {
      type: "button",
      id: "u:c3f9cf5735d8",
      label: "新增",
      actionType: "dialog",
      level: "primary",
      dialog: {
        title: "新增题目",
        body: [
          {
            type: "form",
            api: {
              method: "post",
              url: "http://localhost:8080/question",
              messages: {},
              requestAdaptor: "",
              adaptor: "",
              dataType: "json",
            },
            body: [
              {
                type: "select",
                name: "type",
                label: "类型",
                id: "u:ff6bad9ad4b9",
                options: [
                  {
                    label: "选择题",
                    value: "select",
                  },
                  {
                    label: "填空题",
                    value: "blank",
                  },
                  {
                    label: "主观题（贴图）",
                    value: "picture",
                  },
                ],
                multiple: false,
                value: "picture",
                required: true,
              },
              {
                type: "input-text",
                name: "content",
                label: "内容",
                id: "u:1d53cfdba203",
                required: true,
                clearValueOnHidden: true,
                hiddenOn: "this.type === 'picture'",
              },
              {
                type: "input-image",
                name: "content",
                label: "题目上传",
                id: "u:f2816f575828",
                autoUpload: false,
                proxy: false,
                uploadType: "fileReceptor",
                imageClassName: "r w-full",
                accept: ".jpeg, .jpg, .png, .gif",
                multiple: false,
                hideUploadButton: false,
                hiddenOn: "this.type != 'picture'",
                bos: "default",
                clearValueOnHidden: true,
                required: true,
                receiver: {
                  url: "http://localhost:8080/question/upload",
                  method: "post",
                  requestAdaptor: "",
                  adaptor: "",
                  messages: {},
                  dataType: "form-data",
                },
              },
            ],
            id: "u:c7cf56f52864",
            submitText: "",
            action: [],
          },
        ],
        type: "dialog",
        id: "u:c2ae4318fbe9",
        showCloseButton: true,
        closeOnEsc: false,
        showErrorMsg: true,
        showLoading: true,
      },
    },
    "bulkActions",
  ],
  perPageAvailable: [10],
  messages: {},
  filterColumnCount: 3,
  filter: {
    title: "查询",
    body: [
      {
        type: "group",
        body: [
          {
            type: "input-text",
            name: "id",
            label: "题目ID",
            clearable: true,
            size: "sm",
            id: "u:e059f3565437",
          },
          {
            type: "select",
            label: "题目类型",
            name: "type",
            options: [
              {
                label: "所有类型",
                value: "",
              },
              {
                label: "填空题",
                value: "blank",
              },
              {
                label: "主观题",
                value: "picture",
              },
              {
                label: "选择题",
                value: "select",
              },
            ],
            id: "u:b3fe7a62c54c",
            multiple: false,
            value: "",
            placeholder: "",
          },
        ],
        id: "u:acebf078ad59",
      },
    ],
    actions: [
      {
        type: "submit",
        level: "primary",
        label: "查询",
        id: "u:dcf97f13741b",
      },
    ],
    id: "u:b01098e45095",
  },
  className: "question-manage-table",
  initFetch: true,
  footerToolbar: [
    {
      type: "statistics",
      align: "left",
    },
    {
      type: "pagination",
      align: "right",
    },
  ],
  alwaysShowPagination: true,
};
